<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c"   uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn"  uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="form"uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<%@page import="biblioteca.persistencia.*"%>
<%@page import="biblioteca.dao.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    
    <head>
        <link rel="icon" type="image/vnd.microsoft.icon" href="/favicon.ico"/>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
         <script src="./jQuery/js/jquery-latest.pack.js" type="text/javascript"></script> 
           <script src="./jQuery/js/jquery-1.4.4.min.js" type="text/javascript"></script>
        
        
<script type="text/javascript">
$(document).ready(function(){
        $('#login-trigger').click(function(){
                $(this).next('#login-content').slideToggle();
                $(this).toggleClass('active');                                  

                if ($(this).hasClass('active')) $(this).find('span').html('&#x25B2;')
                        else $(this).find('span').html('&#x25BC;')
                })
});
  </script>
        
    </head>
    
    <body>
          <nav>
        <ul>
                <li id="login">
                    <c:if test="${not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}">
                  <font color="black"><a>Hola <c:out value=" ${usuario.username}, ahora puedes "></c:out></a></font>
                  </c:if>
                    <c:choose>
                        <c:when test="${not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}">
                            <a></a>
                        </c:when>
                            <c:otherwise>
                        <a id="login-trigger">Inicia sesion<span>▼</span></a>
                        <div id="login-content">
                            <form action="/login" method="get">
                                  <fieldset id="inputs">
                                      <input id="username"  name="username" placeholder="Nombre Usuario" required>
                                      <input id="password" type="password" name="password" placeholder="Contraseña" required>
                                  </fieldset>
                                    <fieldset id="actions">
                                          <input type="submit" id="submit" value="conectar">
                                    </fieldset>
                             </form>
                        </div>
                       </c:otherwise>
                        </c:choose>
                </li>                 
                 
                <li id="signup">
                    <c:choose>
                     <c:when test="${not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}">
                       <li><a href="/logout">desconectarte<img src=""></img></a></li>
                     </c:when>
                    <c:otherwise>
                        <a href="ir_registro">Registrate</a>
                        </c:otherwise>
                        </c:choose>
                       
        </ul>
</nav>
        
        
    </body>
    
</html>